<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
	<head>
	
    <title>CBE BPE Toolkit - Report Helper</title>

	<link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/static/anytime/css/anytimec.css"/>
    <link rel="stylesheet" type="text/css" href="/static/jquery-ui/css/smoothness/jquery-ui-1.8.16.custom.css"/>
    <link rel="stylesheet" type="text/css" href="/static/pmp/css/plot.css"/>
    <style type="text/css">
      body {
        padding-top: 55px;
        padding-bottom: 30px;
      }
      .sidebar-nav {
        padding: 5px 0;
      }
    </style>
    
    <script type="text/javascript" src="/static/jquery-1.7.2/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="/static/jquery-ui/js/jquery-ui-1.8.20.custom.min.js"></script>
    <script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/static/sessvars/sessvars.js"></script>
	<script type="text/javascript" src="/static/jquery-printElement/js/jquery.printElement.min.js"></script>
	
	<script type="text/javascript">
		$(document).ready(function(){
			$("li#" + window.location.pathname.substring(5, window.location.pathname.length - 1)).addClass("active") 	
		    $('select#id_name').change(function() { 
	    		var projectId = $(this).val();
	    		sessvars.sessionObj['projectId'] = projectId;
	    		sessvars.$.flush()
	    		getUserCharts();
	    	});
	    	$('#select_all_summary').click(function(){
	    		$('#tc_summary').attr("checked","checked")
	    		$('#lighting_summary').attr("checked","checked")
	    		$('#acoustics_summary').attr("checked","checked")
	    		$('#iaq_summary').attr("checked","checked")
	    	})
	    	$('#select_none_summary').click(function(){
	    		$('#tc_summary').removeAttr("checked")
	    		$('#lighting_summary').removeAttr("checked")
	    		$('#acoustics_summary').removeAttr("checked")
	    		$('#iaq_summary').removeAttr("checked")
	    	})
			getUserCharts();
			$('#generate_report').click(function(){
				included_summary_charts = []
				/*
				if ($('#tc_summary').is(":checked")){included_summary_charts.push('tc_summary')}
				if ($('#lighting_summary').is(":checked")){included_summary_charts.push('lighting_summary')}
				if ($('#acoustics_summary').is(":checked")){included_summary_charts.push('acoustics_summary')}
				if ($('#iaq_summary').is(":checked")){included_summary_charts.push('iaq_summary')}
				*/
				included_user_charts = []
				for (var i=0; i < saved_charts.length; i++){
					if ($('#'+ saved_charts[i]).is(":checked")){included_user_charts.push(saved_charts[i])}
				}
				$.ajax({
					type: "POST",
					url: '/pmp/report/',
					data: JSON.stringify({'included_user_charts': included_user_charts,'included_summary_charts':included_summary_charts,'projectId': sessvars.sessionObj['projectId']}),
					success: function(data){
						$('#reportInline').html(data)
						$('#reportInline').dialog({width:'auto', height:'auto', zIndex:3000})
					}
				});
			})
		});
		function getUserCharts(){
	    	$.ajax({
				type: "GET",
				url: '/pmp/utils/',
				data: {'utilType': 'report_charts','projectId': sessvars.sessionObj['projectId']},
				success: function(data){
					$('#userCharts').html(data)
				}
			});	
    	}
	</script>
  </head>

  <body>
    {% include 'header.html' %}
        <div class="span10" id="mainContent">
        	<div class="row">
        		<div class="span7">
		        	<h3>Report helper tool</h3>
		        	<p>This report helper tool will generate a report consisting of a summary scorecard, charts, and basic explanations.
		        	This page can be printed as a PDF to help facilitate writing a report using the toolkit data analyses. All charts are PNG images which can be saved
		        	by right-clicking and selecting "save image as" from the menu.
		        	The report includes summary background information on both objective measurements and survey questions for each IEQ category.
		        	Additionally, any charts that have been saved from the various IEQ analysis pages can be included by selecting them from the list
		        	below. This report is not intended to be a complete report, but rather a resource for collecting the information gained 
		        	through the analysis process to be used in your own custom report. The report will popup as a separate full-screen dialog. Click the "X" 
		        	on the dialog or press "Esc" to return to this page.
		        	<!--<h5>Summary charts (based on entire project period with a 1-hour resample rate)</h5>
		        	<form class="form-inline" style="margin-top: 5px">
		        		<label class="checkbox"><input type="checkbox" id="tc_summary" checked/>Thermal comfort</label>&nbsp;
		        		<label class="checkbox"><input type="checkbox" id="lighting_summary" checked/>Lighting</label>&nbsp;
		        		<label class="checkbox"><input type="checkbox" id="acoustics_summary" checked/>Acoustics</label>&nbsp;
		        		<label class="checkbox"><input type="checkbox" id="iaq_summary" checked/>IAQ</label>&nbsp;&nbsp;
		        		<a href="#" id="select_all_summary">Select all</a>
		        		&nbsp;|&nbsp;<a href="#" id="select_none_summary">Select none</a>
		        	</form>-->
		        	<h5>Saved charts</h5>
		        	<div id="userCharts" style="margin-top: 5px"></div>
		        	<button class="btn btn-small" id="generate_report">Generate report</button>
		        </div><!--end of intro div-->
        	</div><!--end of intro row-->
        	<div class="row">
        		<div class="span9" id="reportInline" style="margin-top: 15px">
        		</div>
        	</div>
        </div><!--/span10-->
      </div><!--/row-->
      <hr>
		{% include 'footer.html' %}

    </div><!--/.fluid-container-->


<script>
	//console.log(sessvars.sessionObj)
	if (typeof sessvars.sessionObj == 'undefined'){sessvars.sessionObj = {'projectId': $('select#id_name').find("option:selected").val()};}
	if (typeof sessvars.sessionObj != 'undefined'){
		if (sessvars.sessionObj['projectId'] == ""){sessvars.sessionObj['projectId'] = $('select#id_name').find("option:selected").val();}
		else {
			for (var i=0;i<document.getElementById('id_name').options.length;i++) {
				if (document.getElementById('id_name').options[i].value == sessvars.sessionObj['projectId'])
					{document.getElementById('id_name').options[i].selected = true;}
			}
		}
	}

</script>
</body></html>